public class Main {
    public static void main(String[] args) {
        double sum = calculateFactorialSum(30);
        System.out.println("1! + 2! + ...+ 30! 的和为: " + sum);
    }

    public static double calculateFactorialSum(int n) {
        double sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += factorial(i);
        }
        return sum;
    }

    public static double factorial(int num) {
        double result = 1;
        for (int i = 1; i <= num; i++) {
            result *= i;
        }
        return result;
    }
}